<?php

namespace App\Http\Controllers\Api;

use App\Http\Model\Hint;
use App\Model\AdminLog;
use App\Model\Counter;
use App\Model\GiftLibrary;
use App\Model\GiftPearlLibrary;
use App\Model\GiftSpec;
use App\Model\GiftStream;
use App\Model\MallGoods;
use App\Model\MallShoplog;
use App\Model\OperationLogs;
use App\Model\Prop;
use App\Model\CouplingRing;
use App\Model\PropEvent;
use App\Model\PropLog;
use App\Model\PropMall;
use App\Model\Room;
use App\Model\GiftLabel;
use App\Model\GiftLevel;
use App\Model\Users;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;

class GiftController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new GiftLibrary();
    }

    /**
     * 礼物列表
     */
    public function index(Request $request)
    {
        return $this->toJson(self::SUCCESS, $this->model->getList($request));
    }

    /**
     * 礼物新增
     */
    public function store(Request $request)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required|unique:api.gift_library,name|max:50',
            'image' => 'required',
            'price' => 'integer',
            'gift_type' => 'required',
            'classification' => 'required',
            'wealth_num' => 'integer',
            'hot_num' => 'integer',
        ], [
            'name.required' => '礼物名不可为空',
            'name.unique' => '礼物名已存在',
            'name.max' => '礼物名不可超过50个字符',
            'image.required' => '图片不可为空',
            'gift_type.required' => '礼物类型不可为空',
            'classification.required' => '请选择礼物分类',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        if (is_null($data['animate_resource_md5'])) {
            unset($data['animate_resource_md5']);
        }
        if (is_null($data['animate_resource'])) unset($data['animate_resource']);
        $gift = $this->model->createData($data);
        if ($gift['code'] !== 0) {
            return $this->toJson(self::ERROR, $gift['msg']);
        }

        OperationLogs::createData($request, OperationLogs::GIFT, '新增礼物');
        return $this->toJson(self::SUCCESS, $data);
    }

    /**
     * 更新礼物
     */
    public function update(Request $request, $id)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required|max:50',
            'image' => 'required',
            'price' => 'required|integer',
            'wealth_num' => 'integer',
            'hot_num' => 'integer',
        ], [
            'name.required' => '礼物名不可为空',
            'name.unique' => '礼物名已存在',
            'name.max' => '礼物名不可超过50个字符',
            'image.required' => '图片不可为空',
            'price.required' => '价格不可为空',
            'price.integer' => '价格必须为数字',
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $data = $request->except('_url');
        if (is_null($data['animate_resource_md5'])) {
            unset($data['animate_resource_md5']);
        }
        if (is_null($data['animate_resource'])) unset($data['animate_resource']);

        $result = $this->model->updateData($data);
        if ($result['code'] !== 0) {
            return $this->toJson(self::ERROR, $result['msg']);
        }
        OperationLogs::createData($request, OperationLogs::GIFT, '编辑礼物', $id);
        return $this->toJson(self::SUCCESS, $result);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function destroy(Request $request, $id)
    {
        $gift = $this->model->removeData(['gift_id' => $id]);
        if ($gift['code'] !== 0) {
            return $this->toJson(self::ERROR, $gift);
        }
        OperationLogs::createData($request, OperationLogs::GIFT, '删除礼物', $id);
        return $this->toJson();
    }

    /**
     * 设置送礼物可选个数
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     */
    public function setSpecNum(Request $request)
    {
        $spec_num = $request->input('spec_num', '');
        $data = [];
        if ($spec_num) {
            $data = explode(',', $spec_num);
        }
        $giftSpecModel = new GiftSpec();
        OperationLogs::createData($request, OperationLogs::GIFT, '设置礼物可选个数', $spec_num);
        return $this->toJson(self::SUCCESS, $giftSpecModel->setSpecNum($data));
    }

    /**
     * 配置礼物可选个数列表
     * @return \Illuminate\Http\JsonResponse
     */
    public function getGiftSpecs()
    {
        $giftSpecModel = new GiftSpec();
        return $this->toJson(self::SUCCESS, $giftSpecModel->getSpecNums());
    }

    /**
     * 礼物统计
     * @param Request $request
     * @param GiftStream $giftStream
     * @return \Illuminate\Http\JsonResponse
     */
    public function giftsStatistics(Request $request, GiftStream $giftStream)
    {
        $validator = Validator::make($request->all(), [
            'start_date' => 'nullable|date_format:Y-m-d',
            'end_date' => 'nullable|date_format:Y-m-d',
            'type' => 'required', Rule::in(['m', 'd'])
        ], [
            'start_date.date_format' => '开始日期格式错误',
            'end_date.date_format' => '结束日期格式错误',
            'type.required' => '日期格式不可为空',
            'type.in' => '请检查 type 值输入是否正确'
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        return $this->toJson(self::SUCCESS, $giftStream->statisticsGiftStream($request->all()));
    }

    public function remoteSearchGifts(Request $request, GiftLibrary $giftLibrary)
    {
        $name = $request->input('name');
        return $this->toJson(self::SUCCESS, $giftLibrary->getGiftByGiftName($name));
    }

    /**
     * 道具列表
     * @param Request $request
     * @param Prop $prop
     * @return \Illuminate\Http\JsonResponse
     */
    public function getPropList(Request $request, Prop $prop)
    {
        $page = $request->input('page');
        $limit = $request->input('limit');
        $name = $request->input('name');
        $gift_id = $request->input('gift_id');
        $gift_name = $request->input('gift_name');

        $query = $prop;

        $where = [];
        if($name) $where[] = ['name', 'LIKE', "{$name}%"];
        if($gift_id != '') $where[] = ['prop_id', '=', $gift_id];
        if($gift_name != '') $where[] = ['name', 'like', "%{$gift_name}%"];

        return $this->toJson(self::SUCCESS, $query->with(['propEvent.giftLibrary', 'propEvent.giftPearlLibrary', 'propEvent.giftMall'])->where($where)->orderBy('created_at', 'desc')->paginate($limit, ['*'], 'page', $page));
    }

    /**
     * 礼物
     * @param GiftLibrary $giftLibrary
     * @return \Illuminate\Http\JsonResponse
     */
    public function getGift(GiftLibrary $giftLibrary)
    {
        return $this->toJson(self::SUCCESS, $giftLibrary->where(['gift_type' => 1])->get(['gift_id', 'name']));
    }

    /**
     * 道具内容
     * @param PropEvent $propEvent
     * @return \Illuminate\Http\JsonResponse
     */
    public function getPropEventList(PropEvent $propEvent)
    {
        return $this->toJson(self::SUCCESS, $propEvent->get(['name', 'prop_event_id']));
    }

    /*
     * 道具全部列表获取
     * */

    public function getPropAllList(Request $request, Prop $prop)
    {
        return $this->toJson(self::SUCCESS, $prop->getAllList());

    }

    /**
     * 创建道具
     * @param Request $request
     * @param Prop $prop
     * @return \Illuminate\Http\JsonResponse
     */
    public function createProp(Request $request, Prop $prop)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required|unique:api.prop,name',
            'msg' => 'required|string',
            'data_image' => 'required|string',
            'give_type' => ['required', Rule::in([0, 1, 2])]
        ], [
            'name.required' => '道具名不可为空',
            'name.unique' => '道具名已存在',
            'msg.required' => '道具描述不可为空',
            'data_image.required' => '道具图片不可为空',
            'give_type.required' => '道具类型不可为空',
            'give_type.in' => '道具类型不是正确的值'
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $res = $prop->createOrUpdateData($request->only(['name', 'msg', 'data_image','is_present', 'give_type']));
        if ($res['code'] === 0) {
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']);
    }

    /**
     * 编辑道具
     * @param Request $request
     * @param $id
     * @param Prop $prop
     * @return \Illuminate\Http\JsonResponse
     */
    public function updateProp(Request $request, $id, Prop $prop)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required|string',
            'msg' => 'required|string',
            'data_image' => 'required|string',
            'give_type' => ['required', Rule::in([0, 1, 2])],
        ], [
            'name.required' => '道具名不可为空',
            'msg.required' => '道具描述不可为空',
            'data_image.required' => '道具图片不可为空',
            'give_type.required' => '道具类型不可为空',
            'give_type.in' => '道具类型不是正确的值'
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $res = $prop->createOrUpdateData(array_merge($request->only(['name', 'msg', 'data_image', 'give_type' ,'is_present']), ['prop_id' => $id]));
        if ($res['code'] === 0) {
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']);
    }

    /**
     * 创建编辑内容
     * @param Request $request
     * @param PropEvent $propEvent
     * @return \Illuminate\Http\JsonResponse
     * 道具类型（1=礼物id，2=小屋礼物id，3=钻石value，4=珍珠value，5=小屋币value，6=金币value，7=魅力值value，8=财富值value，9=声望值value，10=名人值value，
     * 11=锤子value，12=商场商品id，14=靓号 15=隐身衣 16=足迹清除卡 17=甜蜜蛋糕 18=亲密度直升卡 19=防跟随  23荣耀戒指, 24 荣耀令牌，25CP信物, 26商品(mall_goods)加油卡
     */
    public function createPropEvent(Request $request, PropEvent $propEvent)
    {
        $validator = Validator::make($request->all(), [
            'prop_id' => 'required|exists:api.prop,prop_id',
            'name' => 'required|string',
            'type' => ['required', Rule::in([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 23 ,24, 25, 26])],
//            'data_id' => 'required',
            'data_type' => ['required', Rule::in(1, 2, 3)],
//            'data_min' => 'required|integer',
//            'data_max' => 'required|integer',
//            'data_rand' => 'required',
            'used_at' => 'required'
        ], [
            'prop_id.required' => '道具ID不可为空',
            'prop_id.exists' => '不存在的道具',
            'type.required' => '道具类型不可为空',
            'type.in' => '错误的道具类型',
//            'data_id.required' => 'data_id不可为空',
            'data_type.required' => '数据发放类型不可为空',
            'data_type.in' => '错误的数据发放类型值',
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $res = $propEvent->createOrUpdateData($request->only(['prop_id', 'name', 'type', 'data_id', 'data_type', 'data_min', 'data_max', 'data_rand', 'used_at']));
        if ($res['code'] === 0) {
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']);
    }

    /**
     * 编辑道具内容
     * @param Request $request
     * @param $id
     * @param PropEvent $propEvent
     * @return \Illuminate\Http\JsonResponse
     */
    public function updatePropEvent(Request $request, $id, PropEvent $propEvent)
    {
        $validator = Validator::make($request->all(), [
            'prop_event_id' => 'required|exists:api.prop_event,prop_event_id',
            'prop_id' => 'required|exists:api.prop,prop_id',
            'name' => 'required|string',
            'type' => ['required', Rule::in([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 23 ,24, 25, 26])],
            'data_id' => 'required',
            'data_type' => ['required', Rule::in(1, 2, 3)],
//            'data_min' => 'required|integer',
//            'data_max' => 'required|integer',
//            'data_rand' => 'required',
            'used_at' => 'required'
        ], [
            'prop_event_id.required' => '道具内容ID必须',
            'prop_event_id.exists' => '不存在的道具内容',
            'prop_id.required' => '道具ID不可为空',
            'prop_id.exists' => '不存在的道具',
            'type.required' => '道具类型不可为空',
            'type.in' => '错误的道具类型',
            'data_id.required' => 'data_id不可为空',
            'data_type.required' => '数据发放类型不可为空',
            'data_type.in' => '错误的数据发放类型值',
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $res = $propEvent->createOrUpdateData(array_merge($request->only(['prop_event_id', 'prop_id', 'name', 'type', 'data_id', 'data_type', 'data_min', 'data_max', 'data_rand', 'used_at']), ['prop_event_id' => $id]));
        if ($res['code'] === 0) {
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']);
    }

    /**
     * 赠送道具
     * @param Request $request
     * @param PropLog $propLog
     * @return \Illuminate\Http\JsonResponse
     */
    public function sendProp(Request $request, PropLog $propLog,Users $users)
    {
        $validator = Validator::make($request->all(), [
            'prop_id' => 'required|exists:api.prop_event,prop_id',
            'user_id' => 'required',
            'num' => 'required|integer'
        ], [
            'prop_id.required' => '赠送道具必须',
            'prop_id.exists' => "赠送道具不存在",
            'user_id.required' => '赠送者必须',
//            'user_id.exists' => '赠送者不存在',
            'num.required' => '赠送数量不存在',
            'num.integer' => '赠送数量必须为整数'
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $input = $request->input();
        $user_idArr = explode(',',$input['user_id']);
        $data['prop_id'] = $input['prop_id'];
        $data['suid'] = $input['suid'];
        $data['num'] = $input['num'];
        $data['type'] = $input['type'] ?? 3;
        $data['hammer_type'] = $input['hammer_type'] ?? 2;
        foreach ($user_idArr as $v){
            $data['user_id'] = $v;
            $res = $propLog->sendProp($data);
        }

        if ($res['code'] === 0) {
            return $this->toJson(self::SUCCESS);
        }
        return $this->toJson(self::ERROR, [], $res['msg']);
    }

    //多个房间赠送人气卡
    public function sendPropToRoom(Request $request, Room $room, PropLog $propLog)
    {
        $prop_event_id = 28;//人气卡id
        $room_ids = $request->input('room_ids');
        $num = $request->input('num', 0);
        $check_room = strstr($room_ids, '，');
        if ($check_room) {
            return $this->toJson(self::ERROR, [], '输入的房间合集中存在中文 `，`！  请转换成英文`,`后重试,逗号出现在' . $check_room . '附近');
        }
        $room_id = explode(',', $room_ids);
        $room_info = $room->getRoomInfo($room_id);
        if (empty($room_info)) {
            return $this->toJson(self::ERROR, [], '赠送失败');
        }
        $admin = $this->user;
        foreach ($room_info as $v) {
            $res = $propLog->sendProp(['prop_id' => $prop_event_id, 'user_id' => $v['user_id'], 'num' => $num]);
            if ($res['code'] === 0) {
                $propLog->propLog($admin['id'], $admin['name'], $v['room_id'], $prop_event_id, $num);
            }
        }
        return $this->toJson(self::SUCCESS);
    }

    public function getMorePropLog(Request $request, PropLog $propLog)
    {
        return $this->toJson(self::SUCCESS, $propLog->getList($request->input()));
    }

    //道具商城列表
    public function propMallList(Request $request, PropMall $propMall)
    {
        return $this->toJson(self::SUCCESS, $propMall->getList($request->input()));
    }

    public function allPropList(Request $request, Prop $prop)
    {
        return $this->toJson(self::SUCCESS, $prop->getAllList($request->input()));
    }

    /**
     * 读取所有道具，只读取id和name
     * @return \Illuminate\Http\JsonResponse
     */
    public function samplePropList(Prop $prop)
    {
        return $this->toJson(self::SUCCESS, $prop->get(['prop_id', 'name']));
    }

    //添加道具商城
    public function createPropMall(Request $request, PropMall $propMall)
    {
        $validator = Validator::make($request->all(), [
            'prop_id' => 'required|exists:api.prop,prop_id',
            'goods_name' => 'required',
            'small_img' => 'required',
            'big_img' => 'required',
            'price' => 'required|integer',
        ], [
            'goods_name.required' => '道具名称必须',
            'big_img.required' => '大图必须',
            'small_img.required' => '小图必须',
            'prop_id.exists' => "赠送道具不存在",
            'price.required' => '赠送数量不存在',
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $data = $request->input();
        if (!$data['goods_id']) {
            unset($data['goods_id']);
        }
        return $this->toJson(self::SUCCESS, $propMall->createOrUpdateData($data));
    }

    public function delPropMall(Request $request, PropMall $propMall)
    {
        $id = $request->input('id') ?? 0;
        return $this->toJson(self::SUCCESS, $propMall->delGoods($id));

    }

    /**
     * 商城礼物
     * @param GiftPearlLibrary $giftPearlLibrary
     * @return \Illuminate\Http\JsonResponse
     */
    public function getGiftMall(MallGoods $mallGoods)
    {
        return $this->toJson(self::SUCCESS, $mallGoods->get(['goods_id as gift_id', 'goods_name as name']));
    }


    //宝箱  货架相关
    //货架列表
    public function getCounter(Request $request, Counter $counter)
    {
        return $this->toJson(self::SUCCESS, $counter->getList($request->input()));
    }

    public function delCounter(Request $request, Counter $counter)
    {
        return $this->toJson(self::SUCCESS, $counter->delCounter($request->input()));
    }

    public function createCounter(Request $request, Counter $counter)
    {
        $validator = Validator::make($request->all(), [
            'goods_id' => 'required',
            'goods_type' => 'required',
            'counter_id' => 'required',
        ], [
            'goods_id.required' => '礼物必须',
            'goods_type.required' => '礼物类型必须',
            'counter_id.required' => '货架类型必须',
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $data = $request->input();
        if (empty($data['id'])) {
            unset($data['id']);
        }
        return $this->toJson(self::SUCCESS, $counter->createOrUpdateData($data));
    }

    public function getCounterCate(Request $request, Counter $counter)
    {
        return $this->toJson(self::SUCCESS, $counter->getCate($request->input()));
    }

    public function addCounterCate(Request $request, Counter $counter)
    {

        $validator = Validator::make($request->all(), [
            'name' => 'required',
            'counter_id' => 'required',
        ], [
            'goods_name.required' => '名称必须',
            'counter_id.required' => '货柜id必须',
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $data = $request->input();
        if ($data['counter_cate_id']) {
            $data['id'] = $data['counter_cate_id'];
        }
        unset($data['counter_cate_id']);
        return $this->toJson(self::SUCCESS, $counter->createCate($data));
    }

    public function delCounterCate(Request $request, Counter $counter)
    {
        $data['id'] = $request->input('counter_cate_id');
        return $this->toJson(self::SUCCESS, $counter->delCate($data));

    }

    /**
     * 获取道具流水
     * @param Request $request
     * @param PropLog $propLog
     */
    public function getPropLog(Request $request, PropLog $propLog)
    {
        return $this->toJson(self::SUCCESS, $propLog->getPropLogList($request->input()));
    }

    public function getShopLog(Request $request, MallShoplog $mallShoplog)
    {
        return $this->toJson(self::SUCCESS, $mallShoplog->getShopLogList($request->input()));
    }

    //获取荣誉戒指列表
    public function ringList(Request $request, CouplingRing $couplingRing)
    {
        $page = $request->input('page');
        $limit = $request->input('limit');

        $query = $couplingRing;

        $data = $page && $limit ? $query->where('type', 1)->orderBy('ring_id', 'desc')->paginate($limit, ['*'], 'page', $page) : $query->where('type', 1)->orderBy('ring_id', 'desc')->select('ring_id', 'name')->get();

        if(!$page && !$limit) {
            $data = objToArray($data);
            foreach ($data as $k => $v) {
                $data[$k]['gift_id'] = $v['ring_id'];
            }
        }
        return $this->toJson(self::SUCCESS,  $data);
    }

    //创建戒指
    public function ringCreate(Request $request, CouplingRing $couplingRing)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required',
            'data_image' => 'required',
        ], [
            'name.required' => '戒指名称必须',
            'data_img.required' => '戒指图片必须',
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $data = $request->input();
        $res = $couplingRing->createRing($data);

        OperationLogs::createData($request,OperationLogs::GIFT, '创建戒指');

        if(isset($res['code']) && $res['code'] == 0){
            return $this->toJson(self::SUCCESS, $res);
        }
        return $this->toJson(self::ERROR);
    }

    //编辑戒指
    public function ringEdit(Request $request, $id, CouplingRing $couplingRing)
    {
        $validator = Validator::make($request->all(), [
            'name' => 'required',
            'image' => 'required',
            'ring_id' => 'required|exists:api.coupling_ring,ring_id',
        ], [
            'name.required' => '戒指名称必须',
            'image.required' => '戒指图片必须',
            'ring_id.required' => '戒指ID必须',
            'ring_id.exists' => '戒指不存在'
        ]);

        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $data = $request->input();
        $res = $couplingRing->editRing($id, $data);

        OperationLogs::createData($request,OperationLogs::GIFT, '编辑戒指');

        if(isset($res['code']) && $res['code'] == 0){
            return $this->toJson(self::SUCCESS, $res);
        }
        return $this->toJson(self::ERROR);
    }
    public function label(GiftLabel $giftLabel) {
        return $this->toJson(self::SUCCESS, $giftLabel->getList());
    }
    public function labelDelete(GiftLabel $giftLabel, Request $request ) {
        $id = $request->input('id');
        $result = $giftLabel->removeData(['id' => $id]);
        OperationLogs::createData($request, OperationLogs::GIFT, '删除礼物标签');
        return $this->toJson(self::SUCCESS,$result);
    }
    public function labelAdd(GiftLabel $giftLabel, Request $request ) {
        $validator = Validator::make($request->all(), [
            'image' => 'required',
            'title' => 'required'
        ], [
            'title.required' => '标签名不可为空',
            'image.required' => '图片不可为空',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $label = $giftLabel->createOrUpdate($data);
        if ($label['code'] !== 0) {
            return $this->toJson(self::ERROR, $label['msg']);
        }

        OperationLogs::createData($request, OperationLogs::GIFT, '新增礼物标签');
        return $this->toJson(self::SUCCESS, $data);
    }
    public function labelUpdate(GiftLabel $giftLabel, Request $request ) {
        $validator = Validator::make($request->all(), [
            'id'    => 'required',
            'image' => 'required',
            'title' => 'required'
        ], [
            'id.required'    => '标签id不可为空',
            'title.required' => '标签名不可为空',
            'image.required' => '图片不可为空',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $label = $giftLabel->createOrUpdate($data);
        if ($label['code'] !== 0) {
            return $this->toJson(self::ERROR, $label['msg']);
        }

        OperationLogs::createData($request, OperationLogs::GIFT, '新增礼物标签');
        return $this->toJson(self::SUCCESS, $data);
    }

    public function createOrUpdateCounterNewPlay(Request $request, Counter $counter) {
        $validator = Validator::make($request->all(), [
            'counter_id' => 'required',
            'play_desc' => 'required',
            // 'play_url' => 'required',
            // 'play_icon' => 'required'
        ], [
            'counter_id.required' => '货架不可为空',
            'play_desc.required' => '玩法简介不可为空',
            // 'play_url.required' => '玩法跳转链接不可为空',
            // 'play_icon.required' => '玩法icon不可为空',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $res = $counter->createOrUpdateCounterNewPlay($data);
        // $res = json_decode($res, true);
        if($res['code'] == 0) {
            return $this->toJson(self::SUCCESS);
        } else {
            return $this->toJson(self::ERROR, [], $res['msg']);
        }
    }

    public function getCounterNewPlay(Request $request, Counter $counter) {
        $counterId = $request->get('counter_id', 0);
        $validator = Validator::make($request->all(), [
            'counter_id' => 'required',
        ], [
            'counter_id.required' => '货架不可为空',
        ]);
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }

        $res = $counter->getCounterNewPlay($counterId);
        // if($res) {
            return $this->toJson(self::SUCCESS, $res ?? [
                'id' => 0,
                'counter_id' => 0,
                'play_desc' => '',
                'play_url' => '',
                'play_icon' => '',
                'is_show' => '1'
            ]);
        // } else {
            // return $this->toJson(self::ERROR);
        // }
    }

    /**
     * 获取礼物分类
     *
     * Created at 2021/12/30 18:03
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @return \Illuminate\Http\JsonResponse
     */
    public function getGiftClassification()
    {
        return $this->parseApiResult($this->model->getGiftClassification());
    }

    /**
     * 获取等级数据(财富、魅力、cp)
     *
     * Created at 2021/12/30 18:03
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @return \Illuminate\Http\JsonResponse
     */
    public function getRankData(Request $request)
    {
        return $this->parseApiResult($this->model->getRankData($request->all()));
    }

    /**
     * 礼物等级
     *
     * Created at 2022/11/19
     * @Author 苏龙
     * @return \Illuminate\Http\JsonResponse
     */
    public function level(GiftLevel $giftLevel) {
        return $this->toJson(self::SUCCESS, $giftLevel->getList());
    }
    public function levelDelete(GiftLevel $giftLevel, Request $request ) {
        $id = $request->input('id');
        return $this->toJson(self::SUCCESS, $giftLevel->removeData(['id' => $id]));
    }
    public function levelAdd(GiftLevel $giftLevel, Request $request ) {
        $validator = Validator::make($request->all(), [
            'image' => 'required',
            'title' => 'required',
            'price_begin' => 'required',
            'price_end' => 'required',
        ], [
            'title.required' => '标签名不可为空',
            'image.required' => '图片不可为空',
            'price_begin.required' => '价格区间起始不可为空',
            'price_end.required' => '价格区间截止不可为空',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $level = $giftLevel->createOrUpdate($data);
        if ($level['code'] !== 0) {
            return $this->toJson(self::ERROR, $level['msg']);
        }

        AdminLog::createData($request, AdminLog::GIFT, '新增礼物等级');
        return $this->toJson(self::SUCCESS, $data);
    }
    public function levelUpdate(GiftLevel $giftLevel, Request $request ) {
        $validator = Validator::make($request->all(), [
            'id'    => 'required',
            'image' => 'required',
            'title' => 'required',
            'price_begin' => 'required',
            'price_end' => 'required',
        ], [
            'id.required'    => '标签id不可为空',
            'title.required' => '标签名不可为空',
            'image.required' => '图片不可为空',
            'price_begin.required' => '价格区间起始不可为空',
            'price_end.required' => '价格区间截止不可为空',
        ]);
        $data = $request->except('_url');
        if ($validator->fails()) {
            return $this->toJson(self::PARAM_ERROR, [], $validator->errors()->all()[0]);
        }
        $level = $giftLevel->createOrUpdate($data);
        if ($level['code'] !== 0) {
            return $this->toJson(self::ERROR, $level['msg']);
        }

        AdminLog::createData($request, AdminLog::GIFT, '编辑礼物等级');
        return $this->toJson(self::SUCCESS, $data);
    }

    //幸运礼物列表
    public function luckGiftList(Request $request){
        $res = $this->model->luckGiftList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, $res['data'], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //幸运礼物奖池列表
    public function luckGiftPoolList(Request $request){
        $res = $this->model->luckGiftPoolList($request);
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, $res['data'], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //设置幸运礼物奖池
    public function setLuckGiftPoll(Request $request){
        $res = $this->model->setLuckGiftPoll($request->all());
        if(isset($res['code'])) {
            return $this->toJson(self::ERROR, $res['data'], $res['msg']);
        }
        return $this->toJson(self::SUCCESS, $res);
    }

    //礼物销量
    public function sendList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $startDate = $request->get('startDate','');
        $endDate = $request->get('endDate','');
        $isBag = $request->get('isBag',0);
        $giftId = $request->get('gift_ids',0);
        $data = $this->model->sendList($page, $limit, $startDate, $endDate, $isBag, $giftId);
        return $this->toJson(self::SUCCESS, $data);
    }

    //送礼详情
    public function sendInfo(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $startDate = $request->get('startDate','');
        $endDate = $request->get('endDate','');
        $sendUser = $request->get('from_user_id',0);
        $toUser = $request->get('to_user',0);
        $giftId = $request->get('gift_ids',0);
        $data = $this->model->sendInfo($page, $limit, $startDate, $endDate, $sendUser, $toUser, $giftId);
        return $this->toJson(self::SUCCESS, $data);
    }

    //设置套盒礼物奖池
    public function setSetboxGiftPool(Request $request){
        $res = $this->model->setSetboxGiftPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::GIFT, '设置套盒礼物奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //获取套盒礼物奖池
    public function getSetboxGiftPool(Request $request){
        $res = $this->model->getSetboxGiftPool($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋礼物列表
    public function colorGiftList(Request $request){
        $page = $request->get('page',1);//当前页
        $limit = $request->get('limit',10);//每页显示条数
        //获取数据
        $list = $this->model->colorGiftList($page, $limit);
        return $this->toJson(self::SUCCESS, $list);
    }

    //彩蛋礼物管理-概率配置列表
    public function colorGiftPool(Request $request){
        $page = $request->get('page',1);//当前页
        $limit = $request->get('limit',10);//每页显示条数
        $color_gift_id = $request->get('gift_id',0);//彩蛋礼物id
        if(empty($color_gift_id)){
            return $this->toJson(self::PARAM_ERROR);
        }
        //获取数据
        $list = $this->model->colorGiftPool($page, $limit, $color_gift_id);
        return $this->toJson(self::SUCCESS, $list);
    }

    //彩蛋礼物管理-新增奖池
    public function colorGiftPoolSet(Request $request){
        $gift_id = $request->post('gift_id',0);
        if(empty($gift_id)){
            return $this->toJson(self::PARAM_ERROR);
        }
        $name = $request->post('pool_name',''); //奖池名称
        if(empty($name)){
            return $this->toJson(self::PARAM_ERROR);
        }
        $rate = $request->post('rate',0);//外显概率
        $min_count = $request->post('min_count',0);//奖池最小抽
        $max_count = $request->post('max_count',0);//奖池最大抽
        $hours = $request->post('hours',0);//每小时轮换奖池间隔
        $status = $this->model->colorGiftPoolSet($gift_id, $name, $rate, $min_count, $max_count, $hours);

        if($status['code'] != self::SUCCESS){
            return $this->toJson(self::ERROR, [],$status['msg']);
        }
        return $this->toJson(self::SUCCESS, $status['data'],$status['msg']);
    }

    //彩蛋礼物-编辑奖池
    public function colorGiftEditPool(Request $request){
        $res = $this->model->colorGiftEditPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋编辑奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //获取当前奖池下含有多少个概率配置
    public function getPoolRateList(Request $request){
        $pool_id = $request->get('pool_id');
        $res = $this->model->getPoolRateList($pool_id);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新增奖池下概率配置
    public function addPoolRate(Request $request){
        $res = $this->model->addPoolRate($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋池奖池新增概率配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //删除概率配置
    public function colorGiftRateDel(Request $request){
        $res = $this->model->colorGiftRateDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋池奖池删除概率配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋池礼物查看对应概率下的配置
    public function colorGiftPoolConfigList(Request $request){
        $res = $this->model->colorGiftPoolConfigList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋池礼物列表保存
    public function colorGiftSavePoolConfig(Request $request){
        $res = $this->model->colorGiftSavePoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋池保存奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋奖池开关
    public function colorGiftSetPoolStatus(Request $request){
        $res = $this->model->colorGiftSetPoolStatus($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋设置奖池开启/关闭');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋更新奖池
    public function colorGiftPoolReset(Request $request){
        $res = $this->model->colorGiftPoolReset($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋更新奖池缓存');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋奖池剩余数量
    public function colorGiftPoolConfigNum(Request $request){
        $res = $this->model->colorGiftPoolConfigNum($request->all());
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋礼物上限值配置列表
    public function colorGiftPoolMax(){
        $data = $this->model->colorGiftMaxList();
        return $this->toJson(self::SUCCESS, $data);
    }

    //彩蛋礼物上限配置
    public function colorGiftPoolMaxSet(Request $request){
        $maxOut = $request->post('max_out',0);
        $maxIn = $request->post('max_in',0);
        $res = $this->model->colorGiftPoolMaxSet($maxOut,$maxIn);
        return $this->toJson(self::SUCCESS, $res);
    }

    //彩蛋礼物统计
    public function colorGiftData(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $date_st = $request->input('date_st');
        $date_ed = $request->input('date_ed');
        $date_st = empty($date_st) ? '2024-01-01 00:00:00' : date("Y-m-d 00:00:00", strtotime($date_st));
        $date_ed = empty($date_ed) ? '2054-01-01 00:00:00' : date("Y-m-d 23:59:59", strtotime($date_ed));

        $res = $this->model->colorGiftData($page, $limit, $date_st, $date_ed);
        return $this->toJson(self::SUCCESS, $res);
    }

    //彩蛋爆出统计
    public function colorGiftLog(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);

        $date_st = $request->input('date_st');
        $date_ed = $request->input('date_ed');
        $date_st = empty($date_st) ? '2024-01-01 00:00:00' : date("Y-m-d H:i:s", strtotime($date_st));
        $date_ed = empty($date_ed) ? '2054-01-01 00:00:00' : date("Y-m-d H:i:s", strtotime($date_ed));
        $user_id = $request->input('user_id');//送礼人
        $user_uuid = $request->input('user_uuid');//送礼人

        $res = $this->model->colorGiftLog($page, $limit, $date_st, $date_ed, $user_id, $user_uuid);
        return $this->toJson(self::SUCCESS, $res);
    }

    //彩蛋用户汇总统计数据
    public function colorGiftStat(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);

        $date_st = $request->input('date_st');
        $date_ed = $request->input('date_ed');
        $date_st = empty($date_st) ? '2024-01-01 00:00:00' : date("Y-m-d H:i:s", strtotime($date_st));
        $date_ed = empty($date_ed) ? '2054-01-01 00:00:00' : date("Y-m-d H:i:s", strtotime($date_ed));
        $user_id = $request->input('user_id');//送礼人
        $user_uuid = $request->input('user_uuid');//送礼人

        $res = $this->model->colorGiftStat($page, $limit, $date_st, $date_ed, $user_id, $user_uuid);
        return $this->toJson(self::SUCCESS, $res);
    }

    //新增彩蛋概率banner
    public function colorGiftRateAddBanner(Request $request){
        $res = $this->model->colorGiftRateAddBanner($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋奖池概率新增banner');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //获取彩蛋对应概率下的banner
    public function colorGiftRateBanner(Request $request){
        $res = $this->model->colorGiftRateBanner($request->all());
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }
    
    //查看对应彩蛋下开启池子中的所有礼物
    public function colorWhitePoolGift(Request $request){
        $color_gift_id = $request->get('color_gift_id',0);
        if(empty($color_gift_id)){
            return $this->toJson(self::PARAM_ERROR);
        }
        $res = $this->model->getColorGiftPoolConfig($color_gift_id);
        return $this->toJson(self::SUCCESS,$res);
    }

    //新增彩蛋白名单用户配置
    public function colorGiftWhiteAdd(Request $request){
        $res = $this->model->colorGiftWhiteAdd($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋奖池概率新增白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //编辑彩蛋白名单
    public function colorWhiteEdit(Request $request){
        $res = $this->model->colorWhiteEdit($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋奖池概率编辑白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //删除彩蛋白名单用户
    public function colorWhiteDel(Request $request){
        $deleteId = $request->post('id',0);
        if(empty($deleteId)){
            return $this->toJson(self::PARAM_ERROR);
        }
        $res =  $this->model->colorWhiteDel(['delete_id'=>$deleteId]);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '彩蛋奖池概率删除白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //彩蛋用户白名单列表
    public function colorWhiteList(Request $request){
        $page = $request->get('page',1);
        $limit = $request->get('limit',10);
        $user_id = $request->get('user_id',0);//搜索用户id
        $status = $request->get('status');
        $start_time = $request->get('start_time');
        $end_time = $request->get('end_time');
        $res = $this->model->colorWhiteList($page, $limit, $user_id, $status, $start_time, $end_time);
        return $this->toJson(self::SUCCESS,$res);
    }

    //新幸运礼物新增奖池
    public function luckGiftAddPool(Request $request){
        $res = $this->model->luckGiftAddPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物新增奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物编辑奖池
    public function luckGiftEditPool(Request $request){
        $res = $this->model->luckGiftEditPool($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物编辑奖池');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物新增奖池配置
    public function luckGiftAddPoolConfig(Request $request){
        $res = $this->model->luckGiftAddPoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物新增奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物编辑奖池配置
    public function luckGiftEditPoolConfig(Request $request){
        $res = $this->model->luckGiftEditPoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物编辑奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物删除奖池配置
    public function luckGiftDelPoolConfig(Request $request){
        $res = $this->model->luckGiftDelPoolConfig($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物删除奖池配置');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物更新奖池缓存
    public function luckGiftPoolReset(Request $request){
        $res = $this->model->luckGiftPoolReset($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物更新奖池缓存');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物设置奖池开启/关闭
    public function luckGiftSetPoolStatus(Request $request){
        $res = $this->model->luckGiftSetPoolStatus($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物设置奖池开启/关闭');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物奖池配置剩余数量
    public function luckGiftPoolConfigNum(Request $request){
        $res = $this->model->luckGiftPoolConfigNum($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物奖池配置剩余数量');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物新增白名单
    public function luckGiftAddWhite(Request $request){
        $res = $this->model->luckGiftAddWhite($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物新增白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物删除白名单
    public function luckGiftDelWhite(Request $request){
        $res = $this->model->luckGiftDelWhite($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '新幸运礼物删除白名单');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物奖池列表
    public function luckGiftPoolListV2(Request $request){
        $res = $this->model->luckGiftPoolListV2($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物奖池配置列表
    public function luckGiftPoolConfigList(Request $request){
        $res = $this->model->luckGiftPoolConfigList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物白名单列表
    public function luckGiftWhiteList(Request $request){
        $res = $this->model->luckGiftWhiteList($request, $this->user);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物抽奖明细列表
    public function luckGiftDrawList(Request $request){
        $res = $this->model->luckGiftDrawList($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物抽奖每日统计
    public function luckGiftDayStatistic(Request $request){
        $res = $this->model->luckGiftDayStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //新幸运礼物抽奖用户统计
    public function luckGiftUserStatistic(Request $request){
        $res = $this->model->luckGiftUserStatistic($request);
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //礼物背包流水列表
    public function giftBagLogList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->giftBagLogList($request));
    }

    //用户礼物背包列表
    public function giftBagList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->giftBagList($request));
    }

    //背包礼物来源类型
    public function bagGiftPlatformType(Request $request){
        $res = $this->model->bagGiftPlatformType();
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //背包礼物赠送列表
    public function giveHistory(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->giftGiveHistory($request, $this->user));
    }

    //背包礼物赠送新增
    public function giveAdd(Request $request){
        $res = $this->model->giftGiveAdd($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::GIFT, '背包礼物赠送新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //背包礼物赠送删除
    public function giveDel(Request $request){
        $res = $this->model->giftGiveDel($request->all());
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::GIFT, '背包礼物赠送删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }



















}
